package class2334;

public class Car {private String brand;
    private String model;
    private String engine;

    public Car() {
        System.out.println("调用无参构造方法，无法为属性赋初始值");
    }

    public Car(String brand, String model, String engine) {
        if (brand != null &&!brand.isEmpty() && model != null &&!model.isEmpty() && engine != null &&!engine.isEmpty()) {
            System.out.println("调用有参构造方法，成功为属性赋初始值");
            this.brand = brand;
            this.model = model;
            this.engine = engine;
        } else {
            System.err.println("品牌、型号、发动机参数不能为空");
        }
    }

    public void print() {
        System.out.println("该汽车的品牌为" + brand);
        System.out.println("该汽车的型号为" + model);
        System.out.println("该汽车的发动机为" + engine);
    }

    public void displayInfo() {
        System.out.println("汽车详细信息 - 品牌: " + brand + ", 型号: " + model + ", 发动机: " + engine);
    }
}